/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.aggjpsv.libraryserver.entities;

/**
 *
 * @author SergioPeres
 */
public class Parametros {

    private int port;
    private String pathDir;

    public Parametros() {
        port = 80;
        pathDir = "www";
    }

    public void setParametros(String[] args) {
        if (args.length == 1) {
            try {
                port = Integer.parseInt(args[0]);
            } catch (java.lang.NumberFormatException e) {
                pathDir = args[0];
            }
        } else {
            if (args.length == 2) {
                try {
                    port = Integer.parseInt(args[0]);
                    pathDir = args[1];
                } catch (java.lang.NumberFormatException e) {
                    pathDir = args[0];
                    port = Integer.parseInt(args[1]);
                }
            } else {
                System.out.println("\tErro na passagem de parametros!!!\n"
                        + "\tO servidor utilizara a configuração default.\n "
                        + "\t(dir = \"www\"; port = 80)\n");
            }
        }
    }

    public String getPathDir() {
        return pathDir;
    }

    public int getPort() {
        return port;
    }
}
